namespace Test.Robotics.Runtime
{
    using System;
    using Microsoft.Robotics.Tracing;

    /// <summary>
    /// Mock trace writer for testing
    /// </summary>
    public class MockTracer : ITraceWriter
    {
        /// <summary>
        /// Gets last trace output for inspection
        /// </summary>
        public string LastTrace { get; private set; }

        /// <summary>
        /// Gets or sets the mock time to use when tracing
        /// </summary>
        public DateTime DateToUse { get; set;  }

        /// <summary>
        /// Format and save to trace string for inspection
        /// </summary>
        /// <param name="dateTime">Date time of event</param>
        /// <param name="level">The level</param>
        /// <param name="context">Context of event</param>
        /// <param name="format">Text format</param>
        /// <param name="args">The arguments</param>
        public void WriteLine(DateTime dateTime, TraceContext level, TraceContext context, string format, params object[] args)
        {
            var formatter = new SimpleFormatter();

            this.LastTrace = formatter.Format(this.DateToUse, level, context, format, args);
        }
    }
}
